/*******************************************************************************
 * Copyright (c) 2009 Brian Edginton and Aaron Getz.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Brian Edginton - initial API and implementation
 *     Aaron Getz
 *******************************************************************************/
package org.eclipse.mylyn.internal.eplanner.core;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;

/**
 * 
 * @author edge
 *
 */

public class EPlannerCorePlugin extends Plugin {
	
	public static final String CONNECTOR_KIND = "eplanner";
	
	public static final String ID_PLUGIN = "org.eclipse.mylyn.eplanner";
	
	public static final String ENCODING_UTF_8 = "UTF-8";
	
	private static EPlannerCorePlugin instance;
	
	private EPlannerRepositoryConnector connector;
	
	public EPlannerCorePlugin() {
		
	}
	
	public static EPlannerCorePlugin getDefault() {
		return instance;
	}

	@Override
	public void start(BundleContext context) throws Exception {
		super.start(context);
		instance = this;
	}
	
	@Override
	public void stop(BundleContext context) throws Exception {
		// TODO: check for static config info being saved
		if (instance != null) {
			instance = null;
			super.stop(context);
		}
	}
	
	public EPlannerRepositoryConnector getConnector() {
		return connector;
	}
	
	void setConnector(EPlannerRepositoryConnector connector) {
		this.connector = connector;
	}
	
	protected IPath getRepositoryAttributeCachePath() {
		IPath stateLocation = Platform.getStateLocation(getBundle());
		IPath cacheFile = stateLocation.append("repositoryConfigurations");
		return cacheFile;
	}	
}